package cn.itcast.order.web;

import cn.itcast.order.pojo.Order;
import cn.itcast.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 如果order值都一致，过滤器执行顺序：默认过滤器=》路由匹配过滤器=》全局过滤器
 * 全局过滤器
 */
@RestController
@RequestMapping("order")
public class OrderController {

   @Autowired
   private OrderService orderService;

    @GetMapping("{orderId}")
    public Order queryOrderByUserId(@PathVariable("orderId") Long orderId,@RequestHeader("Truth") String truth) {
        System.out.println("请求头Truth："+truth);
        // 根据id查询订单并返回
        return orderService.queryOrderById(orderId);
    }
}
